package com.jsmy.marketing.utils;

import android.app.Activity;

import com.jsmy.marketing.listener.OnShareBoardListener;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;


/**
 * Created by PC_WLT on 2018/4/26.
 */

public class ShareActionUtils {
    /**
     * 分享平台
     * 分享链接 参数说明
     * https://developer.umeng.com/docs/66632/detail/66639#h3-u5206u4EABu7684u6D88u606Fu7C7Bu578B
     */
    public static final SHARE_MEDIA[] displaylist = new SHARE_MEDIA[]
            {
                    SHARE_MEDIA.WEIXIN_CIRCLE,SHARE_MEDIA.WEIXIN,SHARE_MEDIA.SINA,SHARE_MEDIA.QQ,SHARE_MEDIA.QZONE,SHARE_MEDIA.SMS,SHARE_MEDIA.EMAIL
            };

    /**
     * 处理 默认对象与回调
     * @param context
     * @param shareAction  设置内容参数对象
     *
     *                         activity需要设置
     *                         1.    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);  回调资源
    }
                  2. onDestory 中 设置   UMShareAPI.get(this).release(); 释放资源
     */
    public static void show(Activity context, ShareAction shareAction, UMShareListener onUMShareActionListener){
//        ShareAction shareAction= new ShareAction(context);
        shareAction .withText("hello");
        shareAction .setDisplayList(ShareActionUtils.displaylist);
        shareAction .setShareboardclickCallback(new OnShareBoardListener(context,shareAction,onUMShareActionListener)).open();
    }

}
